class EventEmitter {
    constructor() {
        this.events = {}
    }
    on(event, callback) {
        this.events[event].push(callback)
    }
    emit(...arg) {
        let event = arg[0];
        let params = [].slice.call(arg,1);
        this.events[event].forEach(fn => fn(params));
    }
    off(event, callback) {
       this.events[event] = this.events[event].filter(fn => fn !== callback);
    }
    once(event, callback) {
        let wrapFn = (...arg)=> {
            callback.call(this,arg);
            this.ogg(event,wrapFn)
        }
        this.on(event, wrapFn)
    }

}